Repository navigation
fix(codex): forward tool input that only arrives whole on an output item - #1215
Conversation
The Codex Responses handler kept arguments that arrived only on
response.output_item.done (and custom tool input that arrived on
response.output_item.added) in the builder for history replay, but never
emitted them as tool-call deltas, so the runtime executed the call with an
empty argument string ("path is required").
Route every builder write through one forwardInput helper that also emits
the delta, so the builder holds exactly what the runtime has received. The
added handler forwards whole custom input, the delta handler forwards each
fragment, and the done handler forwards the final input only when nothing
reached the runtime yet, so streamed fragments are never duplicated.
Handler-level coverage spans function and custom calls, with and without
the added item, streamed or final-only, plus custom input on the added
item; a second test drives the same shapes through StreamCompletion and
zeroruntime.CollectStream. Against the unfixed handler the final-only and
input-on-added cases report an empty argument string at tool-call-end.
Closes #1194
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Zero automated PR reviewVerdict: No blockers found Blockers
Validation
ScopeHead: This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality. |
|
No actionable comments were generated in the recent review. WalkthroughThe Codex Responses handler now forwards tool input through a single ChangesCodex tool input forwarding
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Merge Risk:
|
Closes #1194. Supersedes #1201.
This maintainer rebuild carries @oniisanlabs's change from #1201 onto current
main(88ec97d5630be8721e0a3d956f5b198868d0da84) on a fresh branch in Twigpine/zero. The original author remains the Git author; @jatmn is the committer. The rebuild commit's patch is byte-for-byte identical to the original PR's net diff against its merge-base.Original implementation, tests, and bug report credit: @oniisanlabs. Source commit: b6ba46b0 on
oniisanlabs/fix/codex-final-tool-arguments(via fork head for #1201). Review thread and CI history: #1201.Summary
The Codex Responses stream handler kept tool input that arrived only on a whole output item for history replay, but never forwarded it to the runtime as a tool-call delta. A
function_callwhose arguments exist only onresponse.output_item.done, or acustom_tool_callwhose input is already onresponse.output_item.added, therefore reached the agent with an empty argument string and failed with errors such asInvalid arguments for read_file: path is required.Every builder write now goes through one
forwardInputhelper that also emits the delta, sotoolCallBuilder.Argumentsholds exactly what the runtime has received. The added handler forwards whole custom input, the delta handler forwards each fragment, and the done handler forwards the final input only when nothing has reached the runtime yet, so streamed fragments are never duplicated. The check for what still needs forwarding is therefore a check on what was actually sent, as requested on the issue; the invariant is documented on the field.Linked issue
Closes #1194
Verification
From this branch on macOS arm64, using the Go version from
go.mod:make fmt-checkgo vet ./...go test ./...go test -race ./internal/providers/openai -count=1go run ./cmd/zero-release buildgo run ./cmd/zero-release smokemake vulncheckgit diff HEAD --checkmake lint-static: the four pre-existing staticcheck findings (installtest,proxydialtwice,tools/web_fetch), no new findingsOne unrelated failure in the full suite:
internal/tuiTestRelativeAgeFormatsLastActivityfails identically onorigin/mainwhen the host timezone is not UTC and passes withTZ=UTC. Not touched here.Regression evidence
TestCodexOutputItemDoneForwardsUnstreamedArgumentsdrives the handlers directly across function/custom calls, with and without the added item, streamed or final-only input, plus custom input carried on the added item.TestCodexStreamCollectsToolInputDeliveredWholedrives the same shapes throughStreamCompletionandzeroruntime.CollectStream, which is what the agent loop consumes. With the production file restored tomain, both fail:The four streamed cases pass with and without the fix, which pins that already-delivered input is not sent twice.
Checklist
issue-approvedlabel.go build ./...,go vet ./..., andgo test ./...pass locally (see the unrelated timezone note above).gofmtclean.-racewhere relevant).🤖 Generated with Claude Code
Summary by CodeRabbit
Made with Cursor